package com.education.wisdom.controller.app;


import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.education.common.core.BaseController;
import com.education.common.utils.BusinessType;
import com.education.common.utils.LogUtil;
import com.education.wisdom.pojo.Paper;
import com.education.wisdom.service.IPaperService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import lombok.extern.slf4j.Slf4j;


/**
 * 试卷 信息操作处理
 *
 * @author ruoyi
 * @date 2018-11-13
 */
@Controller
@CrossOrigin
@Slf4j
@Api(tags = {"试题库信息"})
@RequestMapping("/appPaper")
public class AppPaperController extends BaseController {
    private String prefix = "system/paper";

    @Autowired
    private IPaperService paperService;

    @GetMapping()
    public String paper() {
        return prefix + "/paper";
    }

    /***
     *
     * @param response
     * @param catalogId    上级编号
     * @param sjLevel    等级
     * @param pageNo 当前页码
     * @throws Exception
     */
    @GetMapping("/all")
    @ResponseBody
    @ApiOperation("查询所有试卷信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "catalogId", value = "课程编号", required = false, dataType = "Integer"),
            @ApiImplicitParam(name = "sjLevel", value = "试卷难易程度（1、困难 2.、中等 3、简单）", required = false, dataType = "String"),
            @ApiImplicitParam(name = "pageNo", value = "当前页码", required = true, dataType = "Integer")})
    public void All(HttpServletResponse response, Integer catalogId, String sjLevel, Integer pageNo) throws Exception {
        Integer pageSize = 20;
        PageHelper.startPage(pageNo.intValue(), pageSize.intValue());
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("catalogId", catalogId);
        map.put("sjLevel", sjLevel);
        log.info(LogUtil.LogInfo("根据难易程度查询所有试卷信息", new Date()));
        PageInfo<Paper> page = new PageInfo<Paper>(paperService.selectAllForPaper(map));
        writeJSON(page, response, "200", "success");

    }


}
